package com.cskaoyan._14network._04test._01moresandre;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

/**
 * @author Macro_Ray
 * @since 2024/3/26 10:11
 */
// 客户端：多次发送数据
public class Client {
    public static void main(String[] args) throws IOException {
        // 1.创建 Socket 客户端对象
        Socket socket = new Socket("127.0.0.1",10086);

        // 2.获取输出流，写数据
        Scanner sc = new Scanner(System.in);
        OutputStream os = socket.getOutputStream();


        while (true) {
            System.out.println("请输入要发送的数据：");
            String str = sc.nextLine();
            if (str.equals("886")){
                break;
            }
            os.write(str.getBytes());
        }


        // 3.关闭 Socket 连接
        socket.close();

    }
}
